package com.bjhb.wuranyuan;

import java.math.BigDecimal;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class NumberUtil {

	public static float getMax(float max) {
		if (max > 1) {
			String strMax = String.valueOf((int) max);
			return (int) Math.pow(10, strMax.length());
		} else {
			BigDecimal d = new BigDecimal(max);
			d.multiply(new BigDecimal(10));
			return d.floatValue();
		}
	}

	public static int getMax(int max) {
		String strMax = String.valueOf((int) max);
		return (int) Math.pow(10, strMax.length());
	}

	public static int getOffset(int max) {
		String strMax = String.valueOf(max);
		return (int) Math.pow(10, strMax.length() - 1);
	}

	public static String getNext(String max) {
		int tmp = Integer.parseInt(max);
		tmp++;
		String t1 = String.valueOf(tmp);
		int size = max.length() - t1.length();
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < size; i++) {
			sb.append("0");
		}
		sb.append(t1);
		return sb.toString();
	}

	public static void main(String[] args) {
		System.out.println(getNext("00000020"));
		Pattern p = Pattern.compile("\\s*|\t|\r|\n");
		String str = "I am a, I am Hello ok, \n new line ffdsa!";
		System.out.println("before:" + str);
		Matcher m = p.matcher(str);
		String after = m.replaceAll("");
		System.out.println("after:" + after);
	}
}
